package com.prj.ufdm.cloud.client;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.web.client.RestTemplate;
import com.prj.ufdm.cloud.client.enums.ServiceNameConsts;
import com.prj.ufdm.cloud.config.RuleConfig;

@SpringBootApplication
@EnableDiscoveryClient
@RibbonClient(name=ServiceNameConsts.SERVICE_MS_TEST,configuration = RuleConfig.class) 
public class EurekaRibbonApplication implements EnvironmentAware { 

	private static Environment env;
	
	@Bean
	@LoadBalanced
	public RestTemplate getRestTemplate() {
		return new RestTemplate();
	}
	
	@Override
	public void setEnvironment(Environment environment) {
		env = environment;
	}
	
	public static void main(String[] args) {
		SpringApplication.run(EurekaRibbonApplication.class, args); 
		System.out.println("Eureka Ribbon " + env.getProperty("server.port") + "启动成功........"); 
	}

}
